package com.xiaoyu.merchant.ui.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.xiaoyu.commonlib.ui.widget.ContainsEmojiEditText;
import com.xiaoyu.merchant.R;


/**
 * @author jx
 * @date 创建时间 2019/01/04
 * @Description 驳回处理
 */
public class HandleRejectionDialog extends Dialog implements View.OnClickListener {

    private Context mContext;
    private View mContentView;
    private TextView mTxtCancel, mTxtModification;
    private ContainsEmojiEditText emojiEditText;

    public HandleRejectionDialog(Context context) {
        super(context, R.style.BaseDialogStyle);
        this.mContext = context;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initView();
    }

    private void initView() {
        mContentView = LayoutInflater.from(mContext).inflate(R.layout.handle_rejection_dialog, null);
        mTxtCancel = mContentView.findViewById(R.id.handle_rejection_dialog_cancel);
        mTxtModification = mContentView.findViewById(R.id.handle_rejection_dialog_confirm);
        emojiEditText = mContentView.findViewById(R.id.handle_rejection_dialog_cause);
        mTxtCancel.setOnClickListener(this);
        mTxtModification.setOnClickListener(this);
        setContentView(mContentView);
    }

    @Override
    public void onClick(View v) {
        if (v == mTxtCancel) {
            dismiss();
        }
        if (v == mTxtModification) {//修改
            if (listener != null) {
                listener.OnHandleRejection(emojiEditText.getText().toString());
            }
        }
    }

    public IMhandleRejectionListener listener;

    public interface IMhandleRejectionListener {
        void OnHandleRejection(String mEditText);
    }
    public void setIMHandleRejection(IMhandleRejectionListener listener) {
        this.listener = listener;
    }

}
